<template>
  <el-table :data="tableData" stripe height="100%">
    <el-table-column
      v-for="column in tableColumns"
      :key="column.code"
      :prop="column.code"
      :label="column.name"
      :width="column.width ? column.width : 100"
      :formatter="
        (row, column, cellValue, index) => {
          return cell_formatter(column, cellValue, tableColumns)
        }
      "
    />
  </el-table>
</template>

<script lang="ts" setup>
import { coil_define } from '@/meta/index'
import { useDbStore } from '@/stores/modules/database'
import type { pd_coil } from '@/types/producedata'
import { fill_ref_info, cell_formatter } from '@/utils/common'
import { onMounted, ref } from 'vue'
const tableColumns = coil_define
const tableData = ref<pd_coil[]>()
const dbStore = useDbStore()
onMounted(() => {
  const tmp = dbStore.coils
  fill_ref_info(tmp, coil_define)
    .then(() => {
      tableData.value = tmp
    })
    .catch((ex) => {
      console.log(ex)
    })
})
</script>
